package crud.client.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

import crud.client.data.Colonne;
import crud.client.dialog.TableCRUD;

public class ColumnInitEvent extends GwtEvent<ColumnInitEvent.ColumnInitEventHandler>
{
	private TableCRUD tableCRUD;
	private Colonne colonne;
	

	public ColumnInitEvent(TableCRUD tableCRUD, Colonne colonne)
	{
		this.tableCRUD = tableCRUD;
		this.colonne = colonne;
	}

	// marker for handler logic in registration method
	public interface ColumnInitEventHandler extends EventHandler
	{
		void onColumnInit(ColumnInitEvent event);
	}

	private static final GwtEvent.Type<ColumnInitEvent.ColumnInitEventHandler> TYPE = new GwtEvent.Type<ColumnInitEventHandler>();

	public static GwtEvent.Type<ColumnInitEventHandler> getType()
	{
		return TYPE;
	}

	@Override
	protected void dispatch(ColumnInitEvent.ColumnInitEventHandler handler)
	{
		handler.onColumnInit(this);
	}

	@Override
	public GwtEvent.Type<ColumnInitEventHandler> getAssociatedType()
	{
		return TYPE;
	}

	public TableCRUD getTableCRUD()
	{
		return tableCRUD;
	}

	public Colonne getColonne()
	{
		return colonne;
	}
	
	@Override
	public String toString()
	{
		
		return "COLUMN INIT: " + tableCRUD.getTable().getLibelle() + " - " + colonne.getLibelle();
	}
	

}
